#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <map>
#include <vector>
#include <unordered_map>
using namespace std;

int main()
{
    int n;
    string s = "shy";
    string str;
    cin >> n >> str;
    vector<int> hash(n);
    int count = 0;
    for (auto ch : str)
    {
        if (ch == 's')
        {
            hash[0]++;
        }
        else if (ch == 'h')
        {
            hash[1]++;
        }
        else if (ch == 'y')
        {
            count += hash[0] * hash[1];
        }
    }
    cout << count << endl;

}